﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;

[CustomEditor( typeof( AlignToEditorCamera ) )]
public class AlignToEditorCameraEditor : Editor
{
    public override void OnInspectorGUI ()
    {
        base.OnInspectorGUI();
    }

    public void OnSceneGUI ()
    {
        var alignCamera = target as AlignToEditorCamera;

        if ( !alignCamera.enabled )
            return;

        if ( alignCamera.autoAlignPosition )
        {
            alignCamera.transform.position = SceneView.lastActiveSceneView.camera.transform.position;
        }

        if ( alignCamera.autoAlignRotation )
        {
            alignCamera.transform.rotation = SceneView.lastActiveSceneView.camera.transform.rotation;
        }
    }
}
